package pro.softzhang.algo.lc300;

import pro.softzhang.algo.common.ListNode;

/**
 *
 */
public class LC328_OddEvenLinkedList {

    public static void main(String[] args) {

    }

    /**
     *
     */
    static
    class Solution {
        public ListNode oddEvenList(ListNode head) {
            if (head == null) {
                return null;
            }
            ListNode odd = head, eventHead = head.next, even = eventHead;
            while (even != null && even.next != null) {
                odd.next = even.next;
                odd = odd.next;
                even.next = odd.next;
                even = even.next;
            }
            odd.next = eventHead;
            return head;
        }
    }
}
